package com.ruoyi.project.er.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.utils.CommonParaTool;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.er.domain.PaeaErError;
import com.ruoyi.project.er.model.PaeaErErrorProcessVo;
import com.ruoyi.project.er.model.PaeaErErrorVo;
import com.ruoyi.project.er.service.IPaeaErErrorProcessService;
import com.ruoyi.project.er.service.IPaeaErErrorService;
import com.ruoyi.project.er.service.IPaeaErPointService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.sql.Date;
import java.util.Arrays;
import java.util.List;

/**
 * 督办创建Controller
 *
 * @author XQ.XU
 * @date 2020-03-20
 */
@Controller
@RequestMapping("/er/paeaErErrorProcess")
public class PaeaErErrorProcessController extends BaseController
{
    private String prefix = "er/paeaErErrorProcess";
    @Resource
    private IPaeaErErrorProcessService paeaErErrorProcessService;
    @Autowired
    private IPaeaErErrorService paeaErErrorService;
    @Autowired
    private IPaeaErPointService paeaErPointService;
    @RequiresPermissions("er:paeaErErrorProcess:view")
    @GetMapping()
    public String paeaErError()
    {

        //return prefix + "/errProcessWelcome";
        return prefix + "/paeaErErrorProcess";
    }

    /**
     * 查询督办查询列表
     */
    @RequiresPermissions("er:paeaErErrorProcess:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(PaeaErErrorVo vo)
    {
        startPage();
        List<PaeaErError> list = paeaErErrorProcessService.queryToDoList(vo);
        return getDataTable(list);
    }


    /**
     * 新增督办查询
     */
   // @GetMapping("/registerErrorPre/{errSource}")
    @GetMapping("/doProcessErrorPre")
    public String doProcessErrorPre(PaeaErError paeaErError,ModelMap mmap)
    {

        //TODO 修改整改日期
        paeaErError.setCorrectLimitDate(new Date(System.currentTimeMillis()));

        //paeaErError=paeaErErrorService.selectPaeaErErrorById(paeaErError.getId());
        //String imgPathPrefix = "http://"+ CommonParaTool.getImgPathPrefix(paeaErError.getAuditOrg());
        //mmap.put("imgPathPrefix", imgPathPrefix);
        mmap.put("paeaErError",paeaErError);
        return prefix + "/doProcessError";
    }

    /**
     * 新增保存督办查询
     */
    @RequiresPermissions("er:paeaErErrorProcess:processError")
    @Log(title = "督办查询", businessType = BusinessType.INSERT)
    @PostMapping("/doProcessError")
    @ResponseBody
    public AjaxResult doProcessError(PaeaErError paeaErError )
    {

        return toAjax(paeaErErrorProcessService.processError(paeaErError));
    }

    /**
     * 修改保存督办查询
     */
    @RequiresPermissions("er:paeaErErrorProcess:edit")
    @Log(title = "督办处理", businessType = BusinessType.UPDATE)
    @PostMapping("/submitWorkFlow")
    @ResponseBody
    public AjaxResult submitWorkFlow(PaeaErErrorProcessVo paeaErError)
    {
        return toAjax(paeaErErrorProcessService.submitWorkFlow(paeaErError));
    }


}
